
import 'package:yp/services/api.dart';
import 'package:get/get.dart';
import 'package:sp_util/sp_util.dart';

import 'state.dart';

class PingJiaShaiDanDetailsLogic extends GetxController {
  final state = PingJiaShaiDanDetailsState();

  @override
  void onInit() {
    super.onInit();
    state.orderMap = Get.arguments;
    state.goodsNumId = Get.parameters['item_num_id'];

    requestData();
  }

  void requestData() {
    var params = {
      'use_platform': 2,
      'ec_shop_num_id': state.orderMap['ec_shop_num_id'],
      'work_flag': '1',
      'tml_num_id': state.orderMap['tml_num_id'],  // 订单号
      'page_size': '100000',
      'page_num': '1',
      'access_token': SpUtil.getString('token'),
      'item_num_id': state.goodsNumId, // 商品id
    };
    Api.queryEvaluateInformation(params).listen((event) {
      print(' 查询成功 返回结果  event = $event');
      if (event['code'] == 0) {
        List list = event['item_infos'];
        if (list.length > 0) {
          state.commentsList = list;
        } else {
          state.commentsList = [];
        }
      } else {
        state.commentsList = [];
      }
      update();
    }, onError: (error) {
      print(' 查询成功 返回结果  error = $error');
      state.commentsList = [];
      update();
    });
  }


}